'use strict'
const pg = require('pg');
let psql = new pg.Pool({
    database: 'running',
    user: 'run',
    port: 5432,
    host: '82.157.94.115',
    password: 'z12345678',
    max: 5
  })

  ;(async()=>{
      let tm = Date.now()
      let id = `${Math.random().toString(16).substring(2)}`
      let sqltext = `INSERT INTO `
      +` content(id,detail,title,add_time,update_time)`
      +` VALUES($1,$2,$3,$4,$5)`
      let r= await psql.query(sqltext,[
          id,`测试内容：${Math.random()}`,'test',
          tm,tm
      ])
      console.log(r)
  
      psql.end()
  })();

//   const query = (psql, callback) => {
//     psql.pg.Pool( (err, connection) => {
//         connection.query(psql, (err, rows) => {
//             callback(err, rows)
//             connection.release() // todo 中断链接
//         })
//     })
// }
exports.psql =psql